k = 0
ss=0
j=0
jj=0
a,b,c =input().split()
numbers=['zero','one','two','three','four','five','six','seven','eight','nine']
if not(a in numbers) or not(b in numbers) or not(c in numbers):
    print('Wrong input')
else:
    n0='zero'
    n1='one'
    n2='two'
    n3='three'
    n4='four'
    n5='five'
    n6='six'
    n7='seven'
    n8='eight'
    n9='nine'
    if a==n0:
        a=0
    elif a==n1:
        a=1
    elif a==n2:
        a=2
    elif a==n3:
        a=3
    elif a==n4:
        a=4
    elif a==n5:
        a=5
    elif a==n6:
        a=6
    elif a==n7:
        a=7
    elif a==n8:
        a=8
    elif a==n9:
        a=9
    if b==n0:
        b=0
    elif b==n1:
        b=1
    elif b==n2:
        b=2
    elif b==n3:
        b=3
    elif b==n4:
        b=4
    elif b==n5:
        b=5
    elif b==n6:
        b=6
    elif b==n7:
        b=7
    elif b==n8:
        b=8
    elif b==n9:
        b=9
    if c==n0:
        c=0
    elif c==n1:
        c=1
    elif c==n2:
        c=2
    elif c==n3:
        c=3
    elif c==n4:
        c=4
    elif c==n5:
        c=5
    elif c==n6:
        c=6
    elif c==n7:
        c=7
    elif c==n8:
        c=8
    elif c==n9:
        c=9

    a=str(a)
    b=str(b)
    c=str(c)

    nd=int(a+b+c)
    n=nd
    nw=str(n)
    len=len(nw)
    if len<3:
        print('Wrong input')
    else:
        def is_prime(n):
            if n <= 1:
                return False
            if n <= 3:
                return True
            if n % 2 == 0 or n % 3 == 0:
                return False
            i = 5
            while i * i <= n:
                if n % i == 0 or n % (i + 2) == 0:
                    return False
                i += 6
            return True

        while ss!=1:
            if is_prime(n):
                nn=n
                ss=1
            else:
                n-=1
                j += 1
        n=nd
        ss=0
        while ss!=1:
            if is_prime(n):
                nn2=n
                ss=1
            else:
                n+=1
                jj += 1
        if j>jj:
            print(nn2)
        else:
            print(nn)